function setHTML(id, v) {
	var e = E(id);
	if (e) e.innerHTML = v;
}

function copyInputValue(id, form) {
	var e = form.getElementsByTagName('input');
	for (var i=0; i<e.length; i++)
		setHTML(id+'.'+e[i].name, e[i].value);
}

function strikeThrough(e) {
	while (e.tagName!='TR')
		e = e.parentNode;
	for (var i=0; i<e.childNodes.length; i++) {
		var c = e.childNodes[i];
		if (c.tagName!='TD') continue;
		c.style.color = '#aaa';
		c.style.textDecoration = 'line-through';
		if (c.innerHTML.indexOf('button')>=0)
			c.innerHTML = '';
	}
}

function getWindowWidth() {
	var w0 = document.documentElement.clientWidth;
	if (w0) return w0;
	var w1 = window.innerWidth;
	var w2 = document.body.offsetWidth;
	if (w1&&w2) return w2;
	if (w1) return w1;
	if (w2) return w2;
	return 0;
}

function getWindowHeight() {
	var h0 = document.documentElement.clientHeight;
	if (h0) return h0;
	var h1 = window.innerHeight;
	var h2 = document.body.offsetHeight;
	if (h1&&h2) return h2;
	if (h1) return h1;
	if (h2) return h2;
	return 0;
}

function C(p, id) {
	while (!p.getElementById)
		p = p.parentNode;
	return p.getElementById(id);
}

function showDialog(title, url, width, height) {
	if (width==null) width = 640;
	if (height==null) height = 360;
	var w = getWindowWidth(), h = getWindowHeight();
	var l = Math.floor((w - width)/2); if (l<0) {l=0; width=w; }
	var t = Math.floor((h - height)/2); if (t<0) {t=0; height=h; }
	/*@cc_on
	@if (@_jscript_version <= 5.6)
	  t += document.documentElement.scrollTop;
	/*@end @*/
	var s = S('diag_mask');
	/*@cc_on
	@if (@_jscript_version <= 5.6)
	  s.top = document.documentElement.scrollTop + 'px';
	/*@end @*/
 	s.display = '';
 	s = S('diag_bg');
	s.display = '';
	s.left = l + 'px';
	s.top = t + 'px';
	s = S('diag_box');
	s.width = width + 'px';
	s.height = height + 'px';
	var e = E('diag_title');
	e.innerHTML = title;
	e = E('diag_body');
	e.style.height = (height-20) + 'px';
	e.innerHTML = '<iframe style="margin:0;padding:0;border:none;width:100%;height:100%;overflow:auto" src="' + url + '"></iframe>';
}

function hideDialog() {
	var s = S('diag_mask');
	s.display = 'none';
	s = S('diag_bg');
	s.display = 'none';
}
